import { createContext } from 'react';
import type {
  DraggableConfig,
  IconType,
  InternalDataNodeForDataMap,
  NodeDragAndRopEventParams,
  TreeNodeProps,
  YmDataNode,
} from '../interface';

interface TreeContextParam {
  prefixCls: string;
  indentWidth: number;
  icon?: IconType;
  switcherIcon?: IconType;
  draggable?: DraggableConfig;
  treeSelectable: boolean;
  treeShowCheckableBox: boolean;
  disabled: boolean;
  keyEntities: Record<string, InternalDataNodeForDataMap>;
  multiple?: boolean;
  onNodeExpand: (
    e: React.MouseEvent<HTMLElement>,
    treeNode: TreeNodeProps,
  ) => void;
  onNodeCheck: (
    e: React.MouseEvent<HTMLElement>,
    treeNode: TreeNodeProps,
  ) => void;
  onNodeSelect: (
    e: React.MouseEvent<HTMLElement>,
    treeNode: TreeNodeProps,
  ) => void;
  treeNodeClassName?: string;
  treeNodeStyle?: React.CSSProperties;
  nodeContentWrapperClassName?: string; //ym-tree-node-content-wrapper
  nodeContentWrapperStyle?: React.CSSProperties;
  titleRender?: (node: YmDataNode) => React.ReactNode;
  onDragStart: (info: NodeDragAndRopEventParams) => void;
  onDragEnter: (info: NodeDragAndRopEventParams) => void;
  onDragOver: (info: NodeDragAndRopEventParams) => void;
  onDragLeave: (info: NodeDragAndRopEventParams) => void;
  onDrop: (info: NodeDragAndRopEventParams) => void;
  onDragEnd: (info: NodeDragAndRopEventParams) => void;
  hoverKey: string | undefined;
  loadData?: (treeNode: YmDataNode) => Promise<any>; //异步加载数据的函数
  showLine?: boolean;
}

const TreeContext = createContext<TreeContextParam | null>(null);

export default TreeContext;
